/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.wholeconsulting.pacc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author pable
 */
@Entity
@Table(name = "FABRICANTES")
@NamedQueries({
    @NamedQuery(name = "Fabricante.findAll", query = "FROM Fabricante a"),
    @NamedQuery(name = "Fabricante.findByNombre", query = "SELECT a from Fabricante a WHERE a.nombre = ?0")})
public class Fabricante implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 4923142815465735487L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "FABRICANTE_ID")
    private Long id;
    @Column(name = "nombre", unique = true, nullable = false)
    private String nombre;
    @OneToMany(mappedBy = "fabricante", cascade = CascadeType.ALL)
    private List<Modelo> modelos;

    public Fabricante() {
        modelos=  new ArrayList<Modelo>();
    }

    
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<Modelo> getModelos() {
        return this.modelos;
    }

    public void setModelos(List<Modelo> modelos) {
        this.modelos = modelos;
    }

    public String getNombre() {
        return this.nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    static public String FIND_ALL = "Fabricante.findAll";
    static public String FIND_BY_NOMBRE = "Fabricante.findByNombre";

    @Override
    public String toString() {
        return this.nombre;
    }
}
